<?php

namespace App\Modules\Admin\Http\Controllers\Apparatus;

use App\Modules\Admin\Http\Controllers\BaseController;
use App\Modules\Admin\Http\Requests\Apparatus\ApparatusRequest;
use App\Modules\Admin\Services\Water\Apparatus\ApparatusService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ApparatusUserController extends BaseController
{
    public function __construct(ApparatusService $apparatusService)
    {
        $this->service = $apparatusService;
    }

    public function create(ApparatusRequest $request): JsonResponse

    {
        return $this->createService($request);
    }

    public function update(ApparatusRequest $request): JsonResponse
    {
        return $this->updateService($request);
    }
    /**
     * 绑定
     * @param Request $request
     * @return JsonResponse
     */
    public function bindUser(Request $request): JsonResponse
    {
        $result = $this->service->bindUser($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 水费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function unbindUser(Request $request): JsonResponse
    {
        $result = $this->service->unbindUser($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
    /**
     * 水费 添加
     * @param Request $request
     * @return JsonResponse
     */
    public function signUser(Request $request): JsonResponse
    {
        $result = $this->service->signUser($request->all());
        if ($result){
            return $this->successJson($result, $this->service->getError());
        }else{
            return $this->errorJson($this->service->getError());
        }
    }
}
